package com.example.administrator.biyesheji_print.Adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;


import com.example.administrator.biyesheji_print.R;
import com.example.administrator.biyesheji_print.Utils.SharedPreferencesUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import droidninja.filepicker.FilePickerBuilder;


/**
 * Created by Administrator on 2018/3/30.
 */

public class PrintAdapter extends CommonAdapter<ArrayList<String>>  {
    ArrayList<String> filePaths;
    private Context context;
    private Fragment mframent;

    public PrintAdapter(Context context, int layoutId, List<ArrayList<String>> datas, Fragment mframent) {
        super(context, layoutId, datas);
        this.context=context;
        this.mframent=mframent;
    }

//    public PrintAdapter(Context context, int layoutId, ArrayList<String> datas, Fragment mframent) {
//        super(context, layoutId, datas);
//        this.context=context;
//       this.mframent=mframent;
//    }






    @Override
    protected void convert(ViewHolder holder, ArrayList<String> strings, final int position) {
//        if (maps.size()!=0){
//            holder.setText(R.id.tv_file,maps.get(position).get("docName").toString());
//        }
//         maps.get(position).get("docName").toString();
        //holder.setText(R.id.tv_file,docName);
        SharedPreferencesUtils.putInt(context,"position",position);
        holder.setOnClickListener(R.id.iv_fileselect, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
                // intent.putExtra("position", position);
                intent.setType("text/plain");
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                SharedPreferencesUtils.putInt(context,"position",position);
                mframent.startActivityForResult(intent,1);
            }
        });
    }



}

